<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>我的藏品 - Surreal Gallery 超现实主义数字藏品平台</title>
    <!-- 引入Font Awesome 6.4.0图标库 -->
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    <style>
        /* 继承首页样式变量 */
        :root {
            --primary: #6a11cb;
            --secondary: #2575fc;
            --accent: #ff2e63;
            --dark: #1a1a2e;
            --light: #f0f0f0;
            --surreal-purple: #8a2be2;
            --surreal-blue: #00b4d8;
            --surreal-pink: #ff6b6b;
            --surreal-yellow: #f9d423;
            --surreal-green: #2ecc71;
        }

        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
        }

        body {
            background: linear-gradient(135deg, var(--dark) 0%, #16213e 100%);
            color: var(--light);
            overflow-x: hidden;
            min-height: 100vh;
        }

        /* 超现实主义背景元素 */
        .floating-elements {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            pointer-events: none;
            z-index: -1;
        }

        .floating-element {
            position: absolute;
            border-radius: 50%;
            opacity: 0.1;
            filter: blur(40px);
            animation: float 15s infinite ease-in-out;
        }

        .floating-element:nth-child(1) {
            width: 300px;
            height: 300px;
            background: var(--surreal-purple);
            top: 10%;
            left: 5%;
            animation-delay: 0s;
        }

        .floating-element:nth-child(2) {
            width: 200px;
            height: 200px;
            background: var(--surreal-blue);
            top: 60%;
            right: 10%;
            animation-delay: 3s;
        }

        .floating-element:nth-child(3) {
            width: 250px;
            height: 250px;
            background: var(--surreal-pink);
            bottom: 10%;
            left: 20%;
            animation-delay: 6s;
        }

        @keyframes float {

            0%,
            100% {
                transform: translateY(0) rotate(0deg);
            }

            50% {
                transform: translateY(-20px) rotate(180deg);
            }
        }

        /* 导航栏 */
        header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 20px 5%;
            position: fixed;
            width: 100%;
            z-index: 1000;
            background: rgba(26, 26, 46, 0.8);
            backdrop-filter: blur(10px);
            border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        }

        .logo {
            font-size: 28px;
            font-weight: 700;
            background: linear-gradient(45deg, var(--surreal-purple), var(--surreal-blue));
            -webkit-background-clip: text;
            background-clip: text;
            color: transparent;
            text-shadow: 0 0 10px rgba(138, 43, 226, 0.3);
        }

        nav ul {
            display: flex;
            list-style: none;
        }

        nav ul li {
            margin-left: 30px;
        }

        nav ul li a {
            color: var(--light);
            text-decoration: none;
            font-weight: 500;
            transition: all 0.3s ease;
            position: relative;
        }

        nav ul li a:hover {
            color: var(--surreal-pink);
        }

        nav ul li a::after {
            content: '';
            position: absolute;
            width: 0;
            height: 2px;
            bottom: -5px;
            left: 0;
            background: linear-gradient(45deg, var(--surreal-purple), var(--surreal-blue));
            transition: width 0.3s ease;
        }

        nav ul li a:hover::after {
            width: 100%;
        }

        .cta-button {
            background: linear-gradient(45deg, var(--surreal-purple), var(--surreal-blue));
            color: white;
            border: none;
            padding: 10px 25px;
            border-radius: 30px;
            font-weight: 600;
            cursor: pointer;
            transition: all 0.3s ease;
            box-shadow: 0 5px 15px rgba(106, 17, 203, 0.4);
        }

        .cta-button:hover {
            transform: translateY(-3px);
            box-shadow: 0 8px 20px rgba(106, 17, 203, 0.6);
        }

        /* 页面标题区域 */
        .page-header {
            padding: 150px 5% 80px;
            text-align: center;
            position: relative;
        }

        .page-title {
            font-size: 3.5rem;
            margin-bottom: 20px;
            background: linear-gradient(45deg, var(--surreal-purple), var(--surreal-blue), var(--surreal-pink));
            -webkit-background-clip: text;
            background-clip: text;
            color: transparent;
            line-height: 1.2;
        }

        .page-subtitle {
            font-size: 1.2rem;
            max-width: 600px;
            margin: 0 auto;
            opacity: 0.8;
            line-height: 1.6;
        }

        /* 我的藏品容器 */
        .my-collections-container {
            max-width: 1400px;
            margin: 0 auto;
            padding: 0 5% 100px;
        }

        /* 藏品控制区域 */
        .collections-controls {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 40px;
            flex-wrap: wrap;
            gap: 20px;
        }

        .search-box {
            position: relative;
            flex: 1;
            min-width: 300px;
            max-width: 400px;
        }

        .search-box input {
            width: 100%;
            padding: 12px 20px 12px 45px;
            border-radius: 30px;
            border: 1px solid rgba(255, 255, 255, 0.2);
            background: rgba(255, 255, 255, 0.05);
            color: var(--light);
            font-size: 1rem;
            backdrop-filter: blur(10px);
        }

        .search-box input:focus {
            outline: none;
            border-color: var(--surreal-purple);
            box-shadow: 0 0 10px rgba(138, 43, 226, 0.3);
        }

        .search-icon {
            position: absolute;
            left: 15px;
            top: 50%;
            transform: translateY(-50%);
            font-size: 1.2rem;
            opacity: 0.7;
            z-index: 2;
        }

        .filter-controls {
            display: flex;
            gap: 15px;
            flex-wrap: wrap;
        }

        .filter-select {
            padding: 10px 20px;
            border-radius: 30px;
            border: 1px solid rgba(255, 255, 255, 0.2);
            background: rgba(255, 255, 255, 0.05);
            color: var(--light);
            font-size: 0.95rem;
            backdrop-filter: blur(10px);
            cursor: pointer;
            transition: all 0.3s ease;
        }

        .filter-select:focus {
            outline: none;
            border-color: var(--surreal-purple);
        }

        .view-toggle {
            display: flex;
            background: rgba(255, 255, 255, 0.05);
            border-radius: 30px;
            padding: 5px;
            backdrop-filter: blur(10px);
        }

        .view-btn {
            width: 40px;
            height: 40px;
            display: flex;
            align-items: center;
            justify-content: center;
            border-radius: 50%;
            cursor: pointer;
            transition: all 0.3s ease;
        }

        .view-btn.active {
            background: linear-gradient(45deg, var(--surreal-purple), var(--surreal-blue));
        }

        /* 藏品统计卡片 */
        .collection-stats {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
            gap: 25px;
            margin-bottom: 40px;
        }

        .stat-card {
            background: rgba(255, 255, 255, 0.05);
            border-radius: 15px;
            padding: 25px;
            backdrop-filter: blur(10px);
            border: 1px solid rgba(255, 255, 255, 0.1);
            display: flex;
            align-items: center;
            gap: 20px;
            transition: all 0.3s ease;
        }

        .stat-card:hover {
            transform: translateY(-5px);
            background: rgba(255, 255, 255, 0.08);
        }

        .stat-icon {
            width: 60px;
            height: 60px;
            border-radius: 50%;
            background: linear-gradient(45deg, var(--surreal-purple), var(--surreal-blue));
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 1.8rem;
            color: white;
        }

        .stat-content {
            flex-grow: 1;
        }

        .stat-number {
            font-size: 2.2rem;
            font-weight: 700;
            margin-bottom: 5px;
            background: linear-gradient(45deg, var(--surreal-purple), var(--surreal-pink));
            -webkit-background-clip: text;
            background-clip: text;
            color: transparent;
        }

        .stat-label {
            font-size: 0.95rem;
            opacity: 0.8;
        }

        /* 藏品网格布局 */
        .collections-grid {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
            gap: 30px;
        }

        .collection-card {
            background: rgba(255, 255, 255, 0.05);
            border-radius: 15px;
            overflow: hidden;
            transition: all 0.3s ease;
            backdrop-filter: blur(10px);
            border: 1px solid rgba(255, 255, 255, 0.1);
            position: relative;
        }

        .collection-card:hover {
            transform: translateY(-10px);
            box-shadow: 0 15px 30px rgba(0, 0, 0, 0.3);
        }

        .collection-image {
            width: 100%;
            height: 250px;
            background: linear-gradient(45deg, var(--surreal-purple), var(--surreal-blue));
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 4rem;
            color: white;
            position: relative;
            overflow: hidden;
        }

        .collection-badge {
            position: absolute;
            top: 15px;
            right: 15px;
            background: rgba(0, 0, 0, 0.7);
            color: white;
            padding: 5px 10px;
            border-radius: 20px;
            font-size: 0.8rem;
            font-weight: 600;
        }

        .collection-actions {
            position: absolute;
            top: 15px;
            left: 15px;
            display: flex;
            gap: 10px;
        }

        .action-btn {
            width: 35px;
            height: 35px;
            border-radius: 50%;
            background: rgba(0, 0, 0, 0.7);
            color: white;
            border: none;
            display: flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            transition: all 0.3s ease;
        }

        .action-btn:hover {
            background: var(--surreal-purple);
            transform: scale(1.1);
        }

        .collection-content {
            padding: 20px;
        }

        .collection-title {
            font-size: 1.3rem;
            margin-bottom: 10px;
            line-height: 1.3;
        }

        .collection-artist {
            display: flex;
            align-items: center;
            margin-bottom: 15px;
            opacity: 0.8;
        }

        .artist-avatar {
            width: 30px;
            height: 30px;
            border-radius: 50%;
            background: linear-gradient(45deg, var(--surreal-purple), var(--surreal-blue));
            margin-right: 10px;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 0.8rem;
            color: white;
        }

        .collection-details {
            display: flex;
            justify-content: space-between;
            margin-bottom: 15px;
            font-size: 0.9rem;
            opacity: 0.7;
        }

        .collection-price {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-top: 15px;
            padding-top: 15px;
            border-top: 1px solid rgba(255, 255, 255, 0.1);
        }

        .price {
            font-weight: 700;
            color: var(--surreal-pink);
            font-size: 1.2rem;
        }

        .view-button {
            background: linear-gradient(45deg, var(--surreal-purple), var(--surreal-blue));
            color: white;
            border: none;
            padding: 8px 20px;
            border-radius: 20px;
            font-weight: 600;
            cursor: pointer;
            transition: all 0.3s ease;
            font-size: 0.9rem;
        }

        .view-button:hover {
            transform: translateY(-2px);
            box-shadow: 0 5px 15px rgba(106, 17, 203, 0.4);
        }

        /* 列表视图样式 */
        .collections-grid.list-view {
            grid-template-columns: 1fr;
        }

        .collection-card.list-view {
            display: flex;
            height: 200px;
        }

        .collection-card.list-view .collection-image {
            width: 200px;
            height: 100%;
            flex-shrink: 0;
        }

        .collection-card.list-view .collection-content {
            flex-grow: 1;
            display: flex;
            flex-direction: column;
            justify-content: space-between;
        }

        .collection-card.list-view .collection-price {
            margin-top: 0;
            padding-top: 0;
            border-top: none;
            justify-content: flex-end;
            gap: 15px;
        }

        /* 空状态 */
        .empty-state {
            text-align: center;
            padding: 80px 20px;
            background: rgba(255, 255, 255, 0.05);
            border-radius: 20px;
            backdrop-filter: blur(10px);
            border: 1px solid rgba(255, 255, 255, 0.1);
        }

        .empty-icon {
            font-size: 5rem;
            color: var(--surreal-purple);
            margin-bottom: 20px;
            opacity: 0.5;
        }

        .empty-title {
            font-size: 1.8rem;
            margin-bottom: 15px;
        }

        .empty-description {
            opacity: 0.7;
            margin-bottom: 30px;
            max-width: 500px;
            margin-left: auto;
            margin-right: auto;
        }

        /* 页脚 */
        footer {
            background: rgba(0, 0, 0, 0.5);
            padding: 50px 5% 20px;
        }

        .footer-content {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
            gap: 40px;
            margin-bottom: 40px;
        }

        .footer-column h3 {
            font-size: 1.2rem;
            margin-bottom: 20px;
            color: var(--surreal-blue);
        }

        .footer-column ul {
            list-style: none;
        }

        .footer-column ul li {
            margin-bottom: 10px;
        }

        .footer-column ul li a {
            color: var(--light);
            text-decoration: none;
            opacity: 0.7;
            transition: all 0.3s ease;
        }

        .footer-column ul li a:hover {
            opacity: 1;
            color: var(--surreal-pink);
        }

        .social-links {
            display: flex;
            gap: 15px;
            margin-top: 20px;
        }

        .social-link {
            width: 40px;
            height: 40px;
            border-radius: 50%;
            background: rgba(255, 255, 255, 0.1);
            display: flex;
            align-items: center;
            justify-content: center;
            transition: all 0.3s ease;
        }

        .social-link:hover {
            background: var(--surreal-purple);
            transform: translateY(-3px);
        }

        .social-links a {
            text-decoration: none;
            color: #fff;
        }

        .copyright {
            text-align: center;
            padding-top: 20px;
            border-top: 1px solid rgba(255, 255, 255, 0.1);
            opacity: 0.7;
        }

        /* 响应式设计 */
        @media (max-width: 968px) {
            .page-title {
                font-size: 2.8rem;
            }

            .collection-stats {
                grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
            }

            .collections-grid {
                grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
            }

            .collection-card.list-view {
                flex-direction: column;
                height: auto;
            }

            .collection-card.list-view .collection-image {
                width: 100%;
                height: 200px;
            }
        }

        @media (max-width: 768px) {
            nav ul {
                display: none;
            }

            .page-header {
                padding: 130px 5% 60px;
            }

            .page-title {
                font-size: 2.2rem;
            }

            .collections-controls {
                flex-direction: column;
                align-items: stretch;
            }

            .search-box {
                min-width: 100%;
                max-width: 100%;
            }

            .filter-controls {
                justify-content: space-between;
            }

            .collection-stats {
                grid-template-columns: 1fr;
            }

            .collections-grid {
                grid-template-columns: 1fr;
            }
        }
    </style>
</head>

<body>
    <!-- 超现实主义背景元素 -->
    <div class="floating-elements">
        <div class="floating-element"></div>
        <div class="floating-element"></div>
        <div class="floating-element"></div>
    </div>

    <!-- 导航栏 -->
    <header>
        <div class="logo">Surreal Gallery</div>
        <nav>
            <ul>
                <li><a href="index.html">首页</a></li>
                <li><a href="collections.html">数字藏品</a></li>
                <li><a href="artists.html">艺术家</a></li>
                <li><a href="news.html">新闻动态</a></li>
                <li><a href="my-collections.html" class="active">我的藏品</a></li>
            </ul>
        </nav>
        <button class="cta-button">连接钱包</button>
    </header>

    <!-- 页面标题区域 -->
    <section class="page-header">
        <h1 class="page-title">我的藏品</h1>
        <p class="page-subtitle">管理您收藏的超现实主义数字艺术品，展示您的独特品味</p>
    </section>

    <!-- 我的藏品容器 -->
    <section class="my-collections-container">
        <!-- 藏品统计 -->
        <div class="collection-stats">
            <div class="stat-card">
                <div class="stat-icon"><i class="fas fa-images"></i></div>
                <div class="stat-content">
                    <div class="stat-number" id="totalCollections">12</div>
                    <div class="stat-label">总藏品数量</div>
                </div>
            </div>
            <div class="stat-card">
                <div class="stat-icon"><i class="fas fa-layer-group"></i></div>
                <div class="stat-content">
                    <div class="stat-number" id="totalValue">24.5 ETH</div>
                    <div class="stat-label">藏品总价值</div>
                </div>
            </div>
            <div class="stat-card">
                <div class="stat-icon"><i class="fas fa-user-friends"></i></div>
                <div class="stat-content">
                    <div class="stat-number" id="artistsCount">8</div>
                    <div class="stat-label">收藏艺术家</div>
                </div>
            </div>
            <div class="stat-card">
                <div class="stat-icon"><i class="fas fa-calendar-alt"></i></div>
                <div class="stat-content">
                    <div class="stat-number" id="firstCollection">2022</div>
                    <div class="stat-label">首次收藏年份</div>
                </div>
            </div>
        </div>

        <!-- 搜索和筛选区域 -->
        <div class="collections-controls">
            <div class="search-box">
                <span class="search-icon"><i class="fas fa-search"></i></span>
                <input type="text" placeholder="搜索我的藏品..." id="searchInput">
            </div>
            <div class="filter-controls">
                <select class="filter-select" id="categoryFilter">
                    <option value="all">所有类别</option>
                    <option value="surrealism">超现实主义</option>
                    <option value="abstract">抽象艺术</option>
                    <option value="digital">数字绘画</option>
                    <option value="3d">3D艺术</option>
                </select>
                <select class="filter-select" id="sortFilter">
                    <option value="newest">最新收藏</option>
                    <option value="oldest">最早收藏</option>
                    <option value="price-high">价格从高到低</option>
                    <option value="price-low">价格从低到高</option>
                    <option value="name">按名称排序</option>
                </select>
                <div class="view-toggle">
                    <div class="view-btn active" data-view="grid"><i class="fas fa-th"></i></div>
                    <div class="view-btn" data-view="list"><i class="fas fa-list"></i></div>
                </div>
            </div>
        </div>

        <!-- 藏品网格布局 -->
        <div class="collections-grid" id="collectionsGrid">
            <!-- 藏品项将通过JavaScript动态生成 -->
        </div>

        <!-- 空状态 -->
        <div class="empty-state" id="emptyState" style="display: none;">
            <div class="empty-icon"><i class="fas fa-box-open"></i></div>
            <h2 class="empty-title">您还没有任何藏品</h2>
            <p class="empty-description">开始探索超现实主义数字艺术世界，收藏您喜爱的独特艺术品。您的收藏将在这里展示。</p>
            <a href="collections.html" class="cta-button">探索藏品</a>
        </div>
    </section>

    <!-- 页脚 -->
    <footer>
        <div class="footer-content">
            <div class="footer-column">
                <h3>Surreal Gallery</h3>
                <p>探索超现实数字艺术的新维度，发现独一无二的数字藏品。</p>
                <div class="social-links">
                    <a href="#" class="social-link"><i class="fab fa-facebook-f"></i></a>
                    <a href="#" class="social-link"><i class="fab fa-twitter"></i></a>
                    <a href="#" class="social-link"><i class="fab fa-instagram"></i></a>
                    <a href="#" class="social-link"><i class="fab fa-weixin"></i></a>
                </div>
            </div>
            <div class="footer-column">
                <h3>快速链接</h3>
                <ul>
                    <li><a href="index.html">首页</a></li>
                    <li><a href="collections.html">数字藏品</a></li>
                    <li><a href="artists.html">艺术家</a></li>
                    <li><a href="news.html">新闻动态</a></li>
                </ul>
            </div>
            <div class="footer-column">
                <h3>支持</h3>
                <ul>
                    <li><a href="#"><i class="fas fa-question-circle"></i> 帮助中心</a></li>
                    <li><a href="#"><i class="fas fa-envelope"></i> 联系我们</a></li>
                    <li><a href="#"><i class="fas fa-users"></i> 社区指南</a></li>
                    <li><a href="#"><i class="fas fa-file-alt"></i> 服务条款</a></li>
                </ul>
            </div>
            <div class="footer-column">
                <h3>订阅更新</h3>
                <p>订阅我们的新闻通讯，获取最新藏品和活动信息。</p>
                <form>
                    <input type="email" placeholder="您的电子邮箱"
                        style="width: 100%; padding: 10px; margin: 10px 0; border-radius: 5px; border: none; background: rgba(255,255,255,0.1); color: white;">
                    <button type="submit" class="cta-button" style="width: 100%;">订阅</button>
                </form>
            </div>
        </div>
        <div class="copyright">
            <p>&copy; 2023 Surreal Gallery. 保留所有权利。</p>
        </div>
    </footer>

    <script>
        // 用户藏品数据
        let userCollections = JSON.parse(localStorage.getItem('userCollections')) || [
            {
                id: 1,
                title: "梦境独角兽",
                artist: "Luna Dreamer",
                artistAvatar: "LD",
                price: 2.5,
                category: "surrealism",
                icon: "fa-horse-head",
                purchaseDate: "2023-05-15",
                badge: "限量版",
                description: "超现实主义艺术家Luna创作的梦幻生物，融合现实与幻想元素。",
                blockchain: "Ethereum",
                edition: "1/10"
            },
            {
                id: 2,
                title: "时间之河",
                artist: "Salvador Reality",
                artistAvatar: "SR",
                price: 1.8,
                category: "abstract",
                icon: "fa-water",
                purchaseDate: "2023-04-22",
                badge: "热卖中",
                description: "流动的时间概念在超现实维度中的具象化表现。",
                blockchain: "Polygon",
                edition: "5/50"
            },
            {
                id: 3,
                title: "悬浮都市",
                artist: "Vera Mirage",
                artistAvatar: "VM",
                price: 3.2,
                category: "3d",
                icon: "fa-building",
                purchaseDate: "2023-03-10",
                badge: "独家",
                description: "反重力建筑群在云端漂浮的超现实城市景观。",
                blockchain: "Ethereum",
                edition: "1/1"
            },
            {
                id: 4,
                title: "星际之门",
                artist: "Fiona Dimension",
                artistAvatar: "FD",
                price: 0.8,
                category: "digital",
                icon: "fa-star",
                purchaseDate: "2023-02-28",
                badge: "新上架",
                description: "连接不同维度的神秘门户，探索未知宇宙的奥秘。",
                blockchain: "Solana",
                edition: "15/100"
            },
            {
                id: 5,
                title: "意识漩涡",
                artist: "Max Surreal",
                artistAvatar: "MS",
                price: 4.5,
                category: "surrealism",
                icon: "fa-rotate",
                purchaseDate: "2023-01-15",
                badge: "拍卖中",
                description: "人类思维与潜意识交织形成的视觉漩涡。",
                blockchain: "Ethereum",
                edition: "1/5"
            },
            {
                id: 6,
                title: "幻影蝴蝶",
                artist: "Luna Dreamer",
                artistAvatar: "LD",
                price: 1.2,
                category: "surrealism",
                icon: "fa-leaf",
                purchaseDate: "2022-12-05",
                badge: "限量版",
                description: "在现实与梦境之间翩翩起舞的神秘生物。",
                blockchain: "Polygon",
                edition: "3/25"
            }
        ];

        // 初始化页面
        document.addEventListener('DOMContentLoaded', function () {
            renderCollections();
            updateStats();
            setupEventListeners();
        });

        // 渲染藏品
        function renderCollections(filteredCollections = null) {
            const collectionsGrid = document.getElementById('collectionsGrid');
            const emptyState = document.getElementById('emptyState');

            const collectionsToRender = filteredCollections || userCollections;

            if (collectionsToRender.length === 0) {
                collectionsGrid.style.display = 'none';
                emptyState.style.display = 'block';
                return;
            }

            collectionsGrid.style.display = 'grid';
            emptyState.style.display = 'none';

            collectionsGrid.innerHTML = '';

            collectionsToRender.forEach(collection => {
                const collectionCard = document.createElement('div');
                collectionCard.className = 'collection-card';
                collectionCard.innerHTML = `
                    <div class="collection-image">
                        <div class="collection-badge">${collection.badge}</div>
                        <div class="collection-actions">
                            <button class="action-btn share-btn" data-id="${collection.id}">
                                <i class="fas fa-share-alt"></i>
                            </button>
                            <button class="action-btn favorite-btn" data-id="${collection.id}">
                                <i class="fas fa-heart"></i>
                            </button>
                        </div>
                        <i class="fas ${collection.icon}"></i>
                    </div>
                    <div class="collection-content">
                        <h3 class="collection-title">${collection.title}</h3>
                        <div class="collection-artist">
                            <div class="artist-avatar">${collection.artistAvatar}</div>
                            <span>${collection.artist}</span>
                        </div>
                        <div class="collection-details">
                            <span>${collection.edition}</span>
                            <span>${collection.blockchain}</span>
                        </div>
                        <p>${collection.description}</p>
                        <div class="collection-price">
                            <span class="price">${collection.price} ETH</span>
                            <button class="view-button" data-id="${collection.id}">查看详情</button>
                        </div>
                    </div>
                `;
                collectionsGrid.appendChild(collectionCard);
            });

            // 添加事件监听器
            document.querySelectorAll('.view-button').forEach(button => {
                button.addEventListener('click', function () {
                    const collectionId = this.getAttribute('data-id');
                    viewCollectionDetails(collectionId);
                });
            });

            document.querySelectorAll('.share-btn').forEach(button => {
                button.addEventListener('click', function () {
                    const collectionId = this.getAttribute('data-id');
                    shareCollection(collectionId);
                });
            });

            document.querySelectorAll('.favorite-btn').forEach(button => {
                button.addEventListener('click', function () {
                    const collectionId = this.getAttribute('data-id');
                    toggleFavorite(collectionId);
                });
            });
        }

        // 更新统计数据
        function updateStats() {
            document.getElementById('totalCollections').textContent = userCollections.length;

            const totalValue = userCollections.reduce((sum, collection) => sum + collection.price, 0);
            document.getElementById('totalValue').textContent = totalValue.toFixed(1) + ' ETH';

            const artists = [...new Set(userCollections.map(collection => collection.artist))];
            document.getElementById('artistsCount').textContent = artists.length;

            if (userCollections.length > 0) {
                const purchaseDates = userCollections.map(collection => new Date(collection.purchaseDate));
                const earliestDate = new Date(Math.min(...purchaseDates));
                document.getElementById('firstCollection').textContent = earliestDate.getFullYear();
            } else {
                document.getElementById('firstCollection').textContent = '--';
            }
        }

        // 设置事件监听器
        function setupEventListeners() {
            // 视图切换
            document.querySelectorAll('.view-btn').forEach(btn => {
                btn.addEventListener('click', function () {
                    document.querySelectorAll('.view-btn').forEach(b => b.classList.remove('active'));
                    this.classList.add('active');

                    const viewType = this.getAttribute('data-view');
                    const grid = document.getElementById('collectionsGrid');

                    if (viewType === 'list') {
                        grid.classList.add('list-view');
                    } else {
                        grid.classList.remove('list-view');
                    }
                });
            });

            // 搜索功能
            document.getElementById('searchInput').addEventListener('input', function () {
                filterCollections();
            });

            // 筛选功能
            document.getElementById('categoryFilter').addEventListener('change', function () {
                filterCollections();
            });

            document.getElementById('sortFilter').addEventListener('change', function () {
                sortCollections();
            });
        }

        // 筛选藏品
        function filterCollections() {
            const searchTerm = document.getElementById('searchInput').value.toLowerCase();
            const categoryFilter = document.getElementById('categoryFilter').value;

            let filtered = userCollections.filter(collection => {
                const matchesSearch = collection.title.toLowerCase().includes(searchTerm) ||
                    collection.artist.toLowerCase().includes(searchTerm) ||
                    collection.description.toLowerCase().includes(searchTerm);

                const matchesCategory = categoryFilter === 'all' || collection.category === categoryFilter;

                return matchesSearch && matchesCategory;
            });

            // 应用当前排序
            const sortFilter = document.getElementById('sortFilter').value;
            filtered = sortCollectionsBy(filtered, sortFilter);

            renderCollections(filtered);
        }

        // 排序藏品
        function sortCollections() {
            const sortFilter = document.getElementById('sortFilter').value;
            const filtered = sortCollectionsBy(userCollections, sortFilter);
            renderCollections(filtered);
        }

        // 根据条件排序藏品
        function sortCollectionsBy(collections, sortBy) {
            const sorted = [...collections];

            switch (sortBy) {
                case 'newest':
                    sorted.sort((a, b) => new Date(b.purchaseDate) - new Date(a.purchaseDate));
                    break;
                case 'oldest':
                    sorted.sort((a, b) => new Date(a.purchaseDate) - new Date(b.purchaseDate));
                    break;
                case 'price-high':
                    sorted.sort((a, b) => b.price - a.price);
                    break;
                case 'price-low':
                    sorted.sort((a, b) => a.price - b.price);
                    break;
                case 'name':
                    sorted.sort((a, b) => a.title.localeCompare(b.title));
                    break;
            }

            return sorted;
        }

        // 查看藏品详情
        function viewCollectionDetails(id) {
            // alert(`查看藏品详情 ID: ${id}\n\n此功能将在后续版本中实现，包括完整的藏品详情页面。`);
            window.open(`collection-detail.html?id=${id}`, '_blank');
        }

        // 分享藏品
        function shareCollection(id) {
            const collection = userCollections.find(c => c.id == id);
            if (navigator.share) {
                navigator.share({
                    title: collection.title,
                    text: collection.description,
                    url: `${window.location.origin}/collection/${id}`
                })
                    .catch(error => console.log('分享失败', error));
            } else {
                alert(`分享藏品: ${collection.title}\n\n复制链接: ${window.location.origin}/collection/${id}`);
            }
        }

        // 收藏/取消收藏
        function toggleFavorite(id) {
            alert(`收藏/取消收藏藏品 ID: ${id}\n\n此功能将在后续版本中实现。`);
        }
    </script>
</body>

</html>